package com.time.timespace.domain.dto;

import com.time.timespace.commons.constant.BaseConstants;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Data
public class ChargeDTO {

    private String month;

    private String type;

    private BigDecimal amount;

    public static List<ChargeDTO> initYearChargeDTO(String year) {
        List<ChargeDTO> yearChargeList = new ArrayList<>(12 * 2);
        for (int i = 1; i <= 12; i++) {
            String month = i < 10 ? "0" + i : String.valueOf(i);
            // 收入数据
            ChargeDTO inChargeDTO = new ChargeDTO();
            inChargeDTO.setType(BaseConstants.ChargeType.IN);
            inChargeDTO.setMonth(year + "-" + month);
            inChargeDTO.setAmount(BigDecimal.ZERO);
            yearChargeList.add(inChargeDTO);
            // 支出数据
            ChargeDTO outChargeDTO = new ChargeDTO();
            outChargeDTO.setType(BaseConstants.ChargeType.OUT);
            outChargeDTO.setMonth(year + "-" + month);
            outChargeDTO.setAmount(BigDecimal.ZERO);
            yearChargeList.add(outChargeDTO);
        }
        return yearChargeList;
    }
}
